package ink.lovejinhu.think.dp;

/**
 * @Author: jin
 * @Date: 2021/9/1 9:49
 * @Version: V1.0
 * @Slogan: Great people are not born great, but show their greatness in the process of growing up
 **/
public class Solution_0213 {
    /**
     * nums是个环
     * num[0]与num[i]是个环
     * *假设小偷偷取第i个房间的在不触发警报的情况下的收益最大值是f(i)
     * <p>
     * 当i=0时，f(0)=num[0]
     * 当i=1时，f(1)=Max(num[0],num[1])
     * 当i>1时   f(i)=Math。max(f(i-1),f(i-2)+nums[i])
     *
     * @param nums
     * @return
     */
    public int rob(int[] nums) {
        int[] maxProfile = new int[nums.length + 1];
        maxProfile[0] = 0;
        maxProfile[1] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            maxProfile[i + 1] = Math.max(maxProfile[i - 2 + 1] + nums[i], maxProfile[i - 1 + 1]);
        }
        return 0;
    }
}
